#include "Info.h"

InfoView::InfoView()
{

}

InfoView::~InfoView()
{

}


CCScene* InfoView::scene()
{
	CCScene* scene = NULL;
	do 
	{
		scene = CCScene::create();
		CC_BREAK_IF(NULL == scene);

		InfoView* layer = InfoView::create();
		CC_BREAK_IF(NULL == layer);

		scene->addChild(layer,1, TAG_BG);

	} while (0);
	return scene;
}

bool InfoView::init()
{
	bool b = false;
	do 
	{
		CCSize size = CCDirector::sharedDirector()->getWinSize();

		CCSprite* bg_sprite = CCSprite::create("787.jpg");
		bg_sprite->setPosition(ccp(size.width / 2, size.height / 2));
		addChild(bg_sprite,0,TAG_BG);


		CCMenuItemImage* pMenuItemImg = CCMenuItemImage::create("b1.png","b2.png",this,menu_selector(InfoView::menuBackLastScene));
		pMenuItemImg->setPosition(ccp( 50, size.height - 50));
		
		CCMenu* pMenu = CCMenu::create(pMenuItemImg,NULL);
		pMenu->setPosition(ccp(0, 0));
		addChild(pMenu, 0, TAG_MENU);

		char* buffer = new char[64];

		Player* p = GameEngine::getInstanse()->player;
		CCLabelTTF* name_label = CCLabelTTF::create(p->getName().c_str(), "MarkerFelt-Thin", 30);
		name_label->setPosition(ccp(160, 320));
		this->addChild(name_label);

		sprintf(buffer, "my left HP is %d", p->getHP());
		CCLabelTTF* HP_label = CCLabelTTF::create(buffer,  "MarkerFelt-Thin", 30);
		HP_label->setPosition(ccp(100, 200));
		this->addChild(HP_label);

		delete[] buffer;

		b = true;
	} while (0);
	return b;
}

void InfoView::ccTouchesBegan(CCSet* pTouch, CCEvent* pEvent)
{


}

void InfoView::menuBackLastScene(CCObject* pSender)
{
	CCScene* scene = MainView::scene();
	CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.5f, scene, ccWHITE));
}